/**
 * Copyright (c) 2010-2011 Pierre Labatut
 *
 * This file is part of Space-Chronicles project.
 *
 * Space-Chronicles is free software: you can redistribute it and/or modify it
 * under the terms of its license which may be found in the accompanying
 * LICENSE file or <http://code.google.com/p/space-chronicles/>.
 */
package space.model;

import java.io.IOException;
import jinngine.math.Matrix4;

/**
 *
 * @author Pierre Labatut
 */
public class StaticCamera implements Camera {

    public StaticCamera(Matrix4 viewpoint, double fovy, double near, double far) {
        this.viewpoint = new Matrix4(viewpoint);
        this.fovy = fovy;
        this.near = near;
        this.far = far;
    }

    public StaticCamera(Camera cam) {
        this(cam.viewpoint(), cam.fovy(), cam.near(), cam.far());
    }
    final Matrix4 viewpoint;
    final double fovy;
    final double near;
    final double far;

    public Matrix4 viewpoint() {
        return new Matrix4(viewpoint);
    }

    public double fovy() {
        return fovy;
    }

    public double near() {
        return near;
    }

    public double far() {
        return far;
    }

    public void printDeclaration(Appendable out)  {
        try {
            out.append("new StaticCamera(\n");
            out.append("new Matrix4(");
            out.append(Double.toString(viewpoint.a11)).append(",");
            out.append(Double.toString(viewpoint.a12)).append(",");
            out.append(Double.toString(viewpoint.a13)).append(",");
            out.append(Double.toString(viewpoint.a14)).append(",\n");
            out.append(Double.toString(viewpoint.a21)).append(",");
            out.append(Double.toString(viewpoint.a22)).append(",");
            out.append(Double.toString(viewpoint.a23)).append(",");
            out.append(Double.toString(viewpoint.a24)).append(",\n");
            out.append(Double.toString(viewpoint.a31)).append(",");
            out.append(Double.toString(viewpoint.a32)).append(",");
            out.append(Double.toString(viewpoint.a33)).append(",");
            out.append(Double.toString(viewpoint.a34)).append(",\n");
            out.append(Double.toString(viewpoint.a41)).append(",");
            out.append(Double.toString(viewpoint.a42)).append(",");
            out.append(Double.toString(viewpoint.a43)).append(",");
            out.append(Double.toString(viewpoint.a44)).append("),\n");
            out.append(Double.toString(fovy)).append(",");
            out.append(Double.toString(near)).append(",");
            out.append(Double.toString(far)).append(");\n");
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}
